runCatchingSuspend

inline suspend fun <R> runCatchingSuspend(crossinline block: suspend () -> R): Result<R>

Executes a suspend function block within a try-catch and returns the result as a Result.

Return

Result representing the success or failure of the provided suspend function.

Parameters

block

A suspend function that returns a result.


inline suspend fun <T, R> T.runCatchingSuspend(crossinline block: suspend T.() -> R): Result<R>

Executes a suspend function block on the receiver T within a try-catch and returns the result as a Result.

Return

Result representing the success or failure of the provided suspend function.

Parameters

block

A suspend function that returns a result, acting on the receiver T.